package 集合.day2.demo5;

public class Stu implements Comparable<Stu>{
    int age;
    String name;

    public Stu(int age, String name) {
        this.age = age;
        this.name = name;
    }

    @Override
    public String toString() {
        return "Stu{" +
                "age=" + age +
                ", name='" + name + '\'' +
                '}';
    }

    public Stu() {
    }

    @Override
    public int compareTo(Stu o) {
        //return age-o.age;
        //return name.compareTo(o.name);
        int rs=age-o.age;
        if(rs!=0){
            return rs;
        }
        return name.compareTo(o.name);
    }
}
